<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>对象运算符的扩展</title>
  <script type="text/javascript">
    let cat = {name: "小花猫", age: 2};
    // let cat2 = cat;
    // console.log("cat=>",cat);//小花猫,2
    // console.log("cat2=>",cat2)//小花猫,2

    // 拷贝对象(深拷贝)
    let cat2 = {...cat};
    cat2.name = "大花猫";
    console.log("cat=>", cat);//小花猫
    console.log("cat2=>", cat2);//大花猫

    // 合并对象[深拷贝]
    let monster = {name: "白骨精", age: 100};
    let car = {brand: "奔驰", price: 800000};
    let monster_car = {...monster,...car};
    monster_car.name = "狐狸精";
    console.log("monster=>", monster);//name: "白骨精", age: 100
    // name: "狐狸精", age: 100, brand: "奔驰", price: 800000
    console.log("monster_car=>", monster_car);
  </script>
</head>
<body>
</body>
</html>
